package o;

import android.net.Uri;
import android.text.TextUtils;
import com.huawei.appmarket.service.activitydispatcher.OpenGateway.Param;
import com.huawei.appmarket.service.reserve.game.bean.WarmUpPageInfo;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.net.URLDecoder;

public class efm {
    private static efm ˋ;
    private static final Object ॱ = new Object();

    public static efm ˏ() {
        efm o_efm;
        synchronized (ॱ) {
            if (ˋ == null) {
                ˋ = new efm();
            }
            o_efm = ˋ;
        }
        return o_efm;
    }

    public WarmUpPageInfo ˏ(String str) {
        try {
            str = URLDecoder.decode(str, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            Logger.e("WarmUpPageInfoProvider", "getWarmUpPageInfo, UnsupportedEncodingException : ");
        } catch (Exception e2) {
            Logger.e("WarmUpPageInfoProvider", "getWarmUpPageInfo, Exception");
        }
        if (ˊ(str)) {
            WarmUpPageInfo warmUpPageInfo = new WarmUpPageInfo();
            Field[] declaredFields = warmUpPageInfo.getClass().getDeclaredFields();
            if (declaredFields.length > 0) {
                Uri parse = Uri.parse(str);
                try {
                    for (Field field : declaredFields) {
                        String name = field.getName();
                        if (!TextUtils.isEmpty(name) && name.endsWith("_")) {
                            boolean isAccessible = field.isAccessible();
                            field.setAccessible(true);
                            ˎ(field, warmUpPageInfo, ceb.ˏ(parse, name.substring(0, name.length() - "_".length())));
                            field.setAccessible(isAccessible);
                        }
                    }
                    return warmUpPageInfo;
                } catch (Throwable e3) {
                    Logger.ˋ("WarmUpPageInfoProvider", "getWarmUpPageInfo, IllegalArgumentException: ", e3);
                    return null;
                } catch (Throwable e32) {
                    Logger.ˋ("WarmUpPageInfoProvider", "getWarmUpPageInfo, SecurityException : ", e32);
                }
            } else {
                Logger.ˏ("WarmUpPageInfoProvider", "getWarmUpPageInfo, fields isEmpty.");
            }
        } else {
            Logger.ˏ("WarmUpPageInfoProvider", "getWarmUpPageInfo, isWarmUpWapPage is false.");
        }
        return null;
    }

    private void ˎ(Field field, WarmUpPageInfo warmUpPageInfo, String str) {
        if (str != null && warmUpPageInfo != null) {
            Class type = field.getType();
            try {
                if (type.getSimpleName().equals(Param.TYPE_STR)) {
                    field.set(warmUpPageInfo, str);
                } else if (type.getSimpleName().equals(Param.TYPE_INT)) {
                    field.set(warmUpPageInfo, Integer.valueOf(str));
                } else if (type.getSimpleName().equals(Param.TYPE_LONG)) {
                    field.set(warmUpPageInfo, Long.valueOf(str));
                } else if (type.getSimpleName().equals("double")) {
                    field.set(warmUpPageInfo, Double.valueOf(str));
                }
            } catch (Throwable e) {
                Logger.ˋ("WarmUpPageInfoProvider", "getWarmUpPageInfo, IllegalAccessException :", e);
            } catch (Throwable e2) {
                Logger.ˋ("WarmUpPageInfoProvider", "getWarmUpPageInfo, IllegalArgumentException :", e2);
            } catch (Throwable e22) {
                Logger.ˋ("WarmUpPageInfoProvider", "getWarmUpPageInfo, SecurityException : ", e22);
            }
        }
    }

    private boolean ˊ(String str) {
        try {
            String queryParameter = Uri.parse(str).getQueryParameter("webType");
            if (queryParameter == null || !queryParameter.equals("10001")) {
                return false;
            }
            return true;
        } catch (Throwable e) {
            Logger.ˋ("WarmUpPageInfoProvider", "isWarmUpWapPage, Exception: ", e);
            return false;
        }
    }
}
